<template>
    <!-- pagesC/pages/admin/supplierInformation -->
    <view>
        <block v-if="isload">
            <form @submit="subform">
                <view class="apply_box">

                    <view class="apply_item">
                        <view class="apply_item-label">绑定ID</view>
                        <view style="flex: 1">
                            <view class="flex" @click="openPopu2">
                                <view class="picker">选择</view>
                                <view style="margin-left: auto;">
                                    →
                                </view>
                            </view>
                        </view>
                    </view>



                    <view class="apply_item">
                        <view class="apply_item-label">供应商名称</view>
                        <view class="flex-y-center">
                            <input type="text" name="linkman" :value="info.linkman" placeholder="请填写供应商名称"></input>
                        </view>
                    </view>

                    <view class="apply_item">
                        <view class="apply_item-label">供应商姓名</view>
                        <view class="flex-y-center">
                            <input type="text" name="linktel" :value="info.linktel" placeholder="请填写供应商姓名"></input>
                        </view>
                    </view>



                    <view class="apply_item">
                        <view class="apply_item-label">供应商电话</view>
                        <view class="flex-y-center">
                            <input type="text" name="desc" :value="info.desc" placeholder="请输入供应商电话"></input>
                        </view>
                    </view>


                    <view class="apply_item">
                        <view class="apply_item-label">经营品类</view>
                        <view style="flex: 1">
                            <view class="flex" @click="openPopu2">
                                <view class="picker">选择</view>
                                <view style="margin-left: auto;">
                                    →
                                </view>
                            </view>
                        </view>
                    </view>


                    <view class="apply_item">
                        <view class="apply_item-label">经营地址</view>
                        <view class="flex-y-center">
                            <input type="text" name="desc" :value="info.desc" placeholder="请输入经营地址"></input>
                        </view>
                    </view>

                    <view class="apply_item">
                        <view class="apply_item-label">持卡人姓名</view>
                        <view class="flex-y-center">
                            <input type="text" name="desc" :value="info.desc" placeholder="请输入持卡人姓名"></input>
                        </view>
                    </view>

                    <view class="apply_item">
                        <view class="apply_item-label">银行卡号</view>
                        <view class="flex-y-center">
                            <input type="text" name="desc" :value="info.desc" placeholder="请输入银行卡号"></input>
                        </view>
                    </view>

                    <view class="apply_item">
                        <view class="apply_item-label">银行</view>
                        <view class="flex-y-center">
                            <input type="text" name="desc" :value="info.desc" placeholder="请输入银行"></input>
                        </view>
                    </view>
                    <view class="apply_item">
                        <view class="apply_item-label">开户银行</view>
                        <view class="flex-y-center">
                            <input type="text" name="desc" :value="info.desc" placeholder="请输入开户银行"></input>
                        </view>
                    </view>
                    <view class="apply_item">
                        <view class="apply_item-label">预留手机号</view>
                        <view class="flex-y-center">
                            <input type="text" name="desc" :value="info.desc" placeholder="请输入预留手机号"></input>
                        </view>
                    </view>

                    <view class="apply_item">
                        <view class="apply_item-label">供应商</view>
                        <view style="flex: 1">
                            <picker @change="cateChange" :value="cindex" :range="cateArr">
                                <view class="flex">
                                    <view class="picker">选择供应商</view>
                                    <view style="margin-left: auto;">
                                        →
                                    </view>
                                </view>
                            </picker>
                        </view>
                    </view>

                    <!-- <view class="apply_item">
                        <view class="apply_item-label">等级</view>
                        <view style="flex: 1">
                            <picker @change="cateChange" :value="cindex" :range="cateArr">
                                <view class="flex">
                                    <view class="picker">选择等级</view>
                                    <view style="margin-left: auto;">
                                        →
                                    </view>
                                </view>
                            </picker>
                        </view>
                    </view> -->

<!--
                    <view class="apply_item">
                        <view class="apply_item-label">是否有售后</view>
                        <view class="flex-y-center">
                            <radio-group class="radio-group" name="is_open">
                                <label><radio value="1" :checked="info.is_open==1?true:false"></radio>是</label>
                                <label><radio value="0" :checked="info.is_open==0?true:false"></radio>否</label>
                            </radio-group>
                        </view>
                    </view> -->



                </view>


                <view class="apply_box">
                    <view class="apply_item" style="border-bottom:0">
                        身份证人像页图片
                    </view>

                    <view class="row-r">
                        <view v-for="(item, index) in idcard_back" :key="index" class="layui-imgbox">
                            <view class="layui-imgbox-close" @tap="removeimg2" :data-index="index" data-field="idcard">
                                <image style="display:block" src="/static/img/ico-del.png"></image>
                            </view>
                            <view class="layui-imgbox-img">
                                <image :src="item" @tap="previewImage" :data-url="item" mode="aspectFill"></image>
                            </view>
                        </view>
                        <image :src="pre_url + '/static/img/idcard.png'" class="uploadbtn" mode="aspectFit" @tap="uploadimg2" data-field="idcard" v-if="idcard_back.length==0"></image>
                        <input type="text" hidden="true" name="idcard_back" :value="idcard_back.join(',')" maxlength="-1"/>
                    </view>

                    <!-- <view class="flex" style="flex-wrap:wrap;padding-bottom:20rpx;">
                        <view v-for="(item, index) in pics" :key="index" class="layui-imgbox">
                            <view class="layui-imgbox-close" @tap="removeimg" :data-index="index" data-field="pics">
                                <image src="/static/img/ico-del.png"></image>
                            </view>
                            <view class="layui-imgbox-img">
                                <image :src="item" @tap="previewImage" :data-url="item" mode="widthFix"></image>
                            </view>
                        </view>
                        <view
                            class="uploadbtn"
                            :style="'background:url('+pre_url+'/static/img/idcard_back.png) no-repeat 60rpx;background-size:140rpx 80rpx;background-color:#F3F3F3;'"
                            @tap="uploadimg" data-field="pics"
                            v-if="pics.length< max_bpic_num"
                        ></view>
                    </view> -->
                    <!-- <input type="text" hidden="true" name="pics" :value="pics.join(',')" maxlength="-1"></input> -->
                </view>

                <view class="apply_box">
                    <view class="apply_item" style="border-bottom:0">
                        身份证国徽页图片
                    </view>
                    <view class="row-r">
                        <view v-for="(item, index) in idcard_back" :key="index" class="layui-imgbox">
                            <view class="layui-imgbox-close" @tap="removeimg2" :data-index="index" data-field="idcard_back">
                                <image style="display:block" src="/static/img/ico-del.png"></image>
                            </view>
                            <view class="layui-imgbox-img">
                                <image :src="item" @tap="previewImage" :data-url="item" mode="aspectFill"></image>
                            </view>
                        </view>
                        <image :src="pre_url + '/static/img/idcard_back.png'" class="uploadbtn" mode="aspectFit" @tap="uploadimg2" data-field="idcard_back" v-if="idcard_back.length==0"></image>
                    </view>
                    <input type="text" hidden="true" name="pics" :value="pics.join(',')" maxlength="-1"></input>
                </view>



                <view class="apply_box">
                    <view class="apply_item" style="border-bottom:0">
                        <view>店铺门头图片</view>
                    </view>
                    <view class="flex" style="flex-wrap:wrap;padding-bottom:20rpx;">
                        <view v-for="(item, index) in pic" :key="index" class="layui-imgbox">
                            <view class="layui-imgbox-close" @tap="removeimg" :data-index="index" data-field="pic"><image src="/static/img/ico-del.png"></image></view>
                            <view class="layui-imgbox-img"><image :src="item" @tap="previewImage" :data-url="item" mode="widthFix"></image></view>
                        </view>
                        <view class="uploadbtn" :style="'background:url('+pre_url+'/static/img/shaitu_icon.png) no-repeat 60rpx;background-size:80rpx 80rpx;background-color:#F3F3F3;'" @tap="uploadimg" data-field="pic" v-if="pic.length==0"></view>
                    </view>
                    <input type="text" hidden="true" name="pic" :value="pic.join(',')" maxlength="-1"></input>
                </view>

                <view class="apply_box">
                    <view class="apply_item">
                        <view class="apply_item-label">供应商</view>
                        <view style="flex: 1">
                            <picker @change="cateChange" :value="cindex" :range="cateArr">
                                <view class="flex">
                                    <view class="picker">选择</view>
                                    <view style="margin-left: auto;">
                                        →
                                    </view>
                                </view>
                            </picker>
                        </view>
                    </view>
                    <view class="apply_item">
                        <view class="apply_item-label">下架商品</view>
                        <view style="flex: 1">
                            <picker @change="cateChange" :value="cindex" :range="cateArr">
                                <view class="flex">
                                    <view class="picker">选择</view>
                                    <view style="margin-left: auto;">
                                        →
                                    </view>
                                </view>
                            </picker>
                        </view>
                    </view>

                    <view class="apply_item">
                        <view class="apply_item-label">是否限制坑位</view>
                        <view style="flex: 1">
                            <picker @change="cateChange" :value="cindex" :range="cateArr">
                                <view class="flex">
                                    <view class="picker">选择</view>
                                    <view style="margin-left: auto;">
                                        →
                                    </view>
                                </view>
                            </picker>
                        </view>
                    </view>

                    <view class="apply_item">
                        <view class="apply_item-label">备注</view>
                        <view class="flex-y-center">
                            <input type="text" name="desc" :value="info.desc" placeholder="请输入备注"></input>
                        </view>
                    </view>

                    <view class="apply_item">
                        <view class="apply_item-label">状态</view>
                        <view style="flex: 1">
                            <picker @change="cateChange" :value="cindex" :range="cateArr">
                                <view class="flex">
                                    <view class="picker">选择</view>
                                    <view style="margin-left: auto;">
                                        →
                                    </view>
                                </view>
                            </picker>
                        </view>
                    </view>
                    <view class="apply_item">
                        <view class="apply_item-label">供应商分类</view>
                        <view style="flex: 1">
                            <picker @change="cateChange" :value="cindex" :range="cateArr">
                                <view class="flex">
                                    <view class="picker">选择</view>
                                    <view style="margin-left: auto;">
                                        →
                                    </view>
                                </view>
                            </picker>
                        </view>
                    </view>
                </view>

            </form>

            <button class="set-btn" form-type="submit" :style="{background:'linear-gradient(90deg,'+t('color1')+' 0%,rgba('+t('color1rgb')+',0.8) 100%)'}">确认提交</button>
        </block>

        <u-popup
            :show="popupShow2"
            :round="10"
            mode="bottom"
            @close="closePopup"
        >
			<view class="popup-background">
                <view class="popup-title ">
                    请选择采购员
                    <view style="position: absolute;right: 0;top: 50%; transform: translate(0, -50%);" @click="closePopup">
                        <u-icon name="close"></u-icon>
                    </view>
                </view>

                <!-- <view class="f1 flex-y-center">
                    <image class="search-ico-img" src="/static/img/search_ico.png"></image>
                    <input :value="keyword" placeholder="输入关键字搜索" placeholder-style="font-size:24rpx;color:#C2C2C2" @confirm="searchConfirm"></input>
                    <!- <input :value="keyword" placeholder="商品搜索..." placeholder-style="font-size:24rpx;color:#C2C2C2" type="text" confirm-type="search" @confirm="search"></input> ->
                </view> -->

                <view class="topsearch flex-y-center">
                    <view class="f1 flex-y-center">
                        <image class="img" src="/static/img/search_ico.png"></image>
                        <input :value="keyword" placeholder="搜索姓名" placeholder-style="font-size:30rpx;color:#C2C2C2" @confirm="searchConfirm" @input="searchChange"></input>
                    </view>
                    <view class="search-btn" @tap="searchbtn">
                        <text>搜索</text>
                    </view>
                </view>

                <view class="popup-title2 popup-item-line">
                    采购员列表
                </view>

                <view class="staffs" @touchmove.stop.prevent>
                    <scroll-view scroll-y style="height: 100%;">
                        <view class="staffs-item popup-item-line" v-for="item in staffsData" :key="item.id" @click="onStaffs(item)">
                            <view class="staffs-name">{{item.name}}</view>
                            <view class="staffs-check flex-y-center">
                                <image
                                    v-if="staffId == item.id"
                                    class="radio-group-img2 radio-group-img3"
                                    src="../../static/userset/group-o.png"
                                    mode="scaleToFill"
                                />
                                <view
                                    v-if="staffId != item.id"
                                    class="radio-group-img2"
                                ></view>
                            </view>
                        </view>
                    </scroll-view>
                </view>

			</view>
		</u-popup>


        <u-popup
            :show="popupShow"
            :round="10"
            :zIndex="10074"
            mode="bottom"
            @close="closePopup"
        >
			<view class="popup-background">
                <view class="popup-title ">
                    请选择可售后条件
                    <view style="position: absolute;right: 0;top: 50%; transform: translate(0, -50%);" @click="closePopup">
                        <u-icon name="close"></u-icon>
                    </view>
                </view>
                <view class="popup-title2 popup-item-line">
                    售后条件 (可多选)
                </view>
                <view class="popup-content">
                    <view v-for="item in shOption1" :key="item.id" class="popup-content-item" @click="selectSH(item.id)">
                        <view class="radio-group-img flex-y-center">
                            <image
                                v-if="shList.includes(item.id)"
                                class="radio-group-img2 radio-group-img3"
                                src="../../static/userset/group-o.png"
                                mode="scaleToFill"
                            />
                            <view
                                v-if="!shList.includes(item.id)"
                                class="radio-group-img2"
                            ></view>
                        </view>
                        <view class="flex-y-center">
                            {{item.name}}
                        </view>
                    </view>
                </view>

                <view class="popup-title2 popup-item-line">
                    免赔情况（可多选）
                </view>
                <view class="popup-content">
                    <view v-for="item in shOption2" :key="item.id" class="popup-content-item" @click="selectSH(item.id)">
                        <view class="radio-group-img flex-y-center">
                            <image
                                v-if="shList.includes(item.id)"
                                class="radio-group-img2 radio-group-img3"
                                src="../../static/userset/group-o.png"
                                mode="scaleToFill"
                            />
                            <view
                                v-if="!shList.includes(item.id)"
                                class="radio-group-img2"
                            ></view>
                        </view>
                        <view class="flex-y-center">
                            {{item.name}}
                        </view>
                    </view>
                </view>



			</view>
		</u-popup>


        <loading v-if="loading"></loading>
        <dp-tabbar :opt="opt"></dp-tabbar>
        <popmsg ref="popmsg"></popmsg>
        <wxxieyi></wxxieyi>
    </view>
</template>

<script>
    var app = getApp();

    export default {
      data() {
        return {
            opt:{},
            keyword:'',
            idcard:[],
			idcard_back:[],
            popupShow2:false,
            popupShow:false,
            loading:false,
          isload: false,
            menuindex:-1,
            pre_url:app.globalData.pre_url,
            shOption1:[
                {id:1, name:'腐烂超4%可售后（正常损耗：10斤以下正负0.5斤；10斤以上正负1斤)'},
                {id:2, name:'腐烂超5%可售后（正常损耗：10斤以下正负0.5斤；10斤以上正负1斤)'},
                {id:3, name:'腐烂超3%可售后（正常损耗：10斤以下正负0.5斤；10斤以上正负1斤)'},
                {id:4, name:'掉粒超过5%可售后，掉粒脱落严重，碰伤严重，挤压伤，腐烂5%有售后'},
                {id:5, name:'腐烂、虫果可售后（虫果、烂刺、腐烂三房以上，整颗赔付）'},
            ],
            shOption2:[
                {id:1001, name:'腐烂可售后，机械伤、枝伤、掉把不赔付&nbsp;(腐烂超3%赔付)'},
                {id:1002, name:'正常损耗：10斤以下正负0.5斤；10斤以上正负1斤'},
                {id:1003, name:'免赔: 口感、颜色.大小等差异'},
                {id:1004, name:'掉粒超过5%可售后，掉粒脱落严重，碰伤严重，挤压伤，腐烂5%有售后'},
                {id:1005, name:'单串腐烂提整件售后情况，不予处理'},
            ],
            staffId: -1,
            staffsData:[
                {id:1001, name:'李四'},
                {id:1002, name:'张券'},
                {id:1003, name:'李券'},
                {id:1004, name:'元用'},
                {id:1005, name:'李六'},
                {id:1007, name:'李四'},
                {id:1008, name:'张券'},
                {id:1009, name:'李券'},
                {id:1010, name:'元用'},
                {id:1011, name:'李六'},
                {id:1012, name:'元用'},
                {id:1013, name:'李六'},
                {id:1014, name:'元用'},
                {id:1015, name:'李六'},
                {id:1016, name:'元用'},
                {id:1017, name:'李六'},
                {id:1018, name:'元用'},
                {id:1019, name:'李六'},
                {id:1020, name:'元用'},
                {id:1021, name:'李六'},
            ],
            shList: [],
          datalist: [],
          pagenum: 1,
          cateArr: [],
          cindex: 0,
          isagree: false,
          showxieyi: false,
                pic:[],
                pics:[],
                zhengming:[],
          info: {},
                bset:{},
          latitude: '',
          longitude: '',
          address:'',
          min_bpic_num:3,
          max_bpic_num:5,
          queue_free_set:[],
          //自定义表单Start
          has_custom:0,
          show_custom_field:false,
          regiondata:'',
          editorFormdata:{},
          test:'',
          formfields:[],
          custom_formdata:[],
          items: [],
          formvaldata:{},
          submitDisabled:false,
          register_forms:[],
          //自定义表单End
          active_coin:0
        };
      },

      onLoad: function (opt) {
            this.opt = app.getopts(opt);
            this.loaded();
      },
        onPullDownRefresh: function () {
        },
      methods: {
            getdata: function () {
                var that = this;
                that.loading = true;
                app.get('ApiBusiness/apply', {}, function (res) {
                    that.loading = false;
                    if (res.status == 2) {
                        app.alert(res.msg, function () {
                            app.goto('/admin/index/index', 'redirect');
                        })
                        return;
                    }
                    uni.setNavigationBarTitle({
                        title: res.title
                    });
                    var clist = res.clist;
                    var cateArr = [];
                    for (var i in clist) {
                        cateArr.push(clist[i].name);
                    }
                    var pics = res.info ? res.info.pics : '';
                    if (pics) {
                        pics = pics.split(',');
                    } else {
                        pics = [];
                    }
                    var zhengming = res.info ? res.info.zhengming : '';
                    if (zhengming) {
                        zhengming = zhengming.split(',');
                    } else {
                        zhengming = [];
                    }
                    //自定义表单
                    if(res.has_custom){
                        if(res.register_forms){
                            that.editorFormdata = res.register_forms;
                            that.formvaldata = res.formvaldata;
                        }
                        that.formfields = res.custom_form_field;
                        that.has_custom = res.has_custom
                        that.show_custom_field = true
                        uni.request({
                            url: app.globalData.pre_url+'/static/area.json',
                            data: {},
                            method: 'GET',
                            header: { 'content-type': 'application/json' },
                            success: function(res2) {
                                that.items = res2.data
                            }
                        });
                    }
                    //自定义表单end
                    that.clist = res.clist
                    that.bset = res.bset
                    if(that.bset.nearby){
                        that.min_bpic_num =6;
                        that.max_bpic_num =8;
                    }
                    that.info = res.info
            that.address = res.info.address;
            that.latitude = res.info.latitude;
            that.longitude = res.info.longitude;
                    that.cateArr = cateArr;
                    that.pic = res.info.pic ? [res.info.pic] : [];
                    that.pics = pics;
                    that.zhengming = zhengming;
                    that.active_coin = res.active_coin;
                    that.queue_free_set = res.queue_free_set;
                    that.loaded();
                });
            },
        cateChange: function (e) {
          this.cindex = e.detail.value;
        },
        locationSelect: function () {
          var that = this;
          uni.chooseLocation({
            success: function (res) {
              that.info.address = res.name;
                        that.info.latitude = res.latitude;
              that.info.longitude = res.longitude;
              that.address = res.name;
              that.latitude = res.latitude;
              that.longitude = res.longitude;
            }
          });
        },
        subform: function (e) {
          var that = this;
          var info = e.detail.value;
          if (info.linkman == '') {
            app.error('请填写联系人姓名');
            return false;
          }
          if (info.linktel == '') {
            app.error('请填写联系人手机号');
            return false;
          }
          if(!app.isPhone(info.linktel)){
              return app.error('请填写正确的手机号');
          }

          if (info.tel == '') {
            app.error('请填写客服电话');
            return false;
          }
          if(!app.isPhone(info.tel) && !app.isPhone(info.tel, 2) && !app.isPhone(info.tel, 3)){
              return app.error('请填写正确的客服电话');
          }
          if (info.name == '') {
            app.error('请填写商家名称');
            return false;
          }
          if (info.zuobiao == '') {
            //app.error('请选择店铺坐标');
            //return false;
          }
          if (info.address == '') {
            app.error('请填写店铺地址');
            return false;
          }
          if (info.pic == '') {
            app.error('请上传商家logo');
            return false;
          }
          if (info.pics == '') {
            app.error('请上传商家照片');
            return false;
          }
          if (info.zhengming == '') {//$.error('请上传证明材料');return false;
          }
          if (info.un == '') {
            app.error('请填写登录账号');
            return false;
          }
          if (info.pwd == '') {
            app.error('请填写登录密码');
            return false;
          }
          var pwd = info.pwd;
          if (pwd.length < 6) {
            app.error('密码不能小于6位');
            return false;
          }
          if (info.repwd != info.pwd) {
            app.error('两次输入密码不一致');
            return false;
          } //if(!/(^0?1[3|4|5|6|7|8|9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$)/.test(tel)){
          //	dialog('手机号格式错误');return false;
          //}
          //info.address = that.address;
          info.latitude = that.latitude;
          info.longitude = that.longitude;
          if (that.bset.xieyi_show == 1 && !that.isagree) {
            app.error('请先阅读并同意商户入驻协议');
            return false;
          }
          info.cid = that.clist[that.cindex].id;
          if (that.info && that.info.id) {
            info.id = that.info.id;
          }
          //如果有自定义表单则验证表单内容
          if(that.show_custom_field){
              var customformdata = {};
              var customData = that.checkCustomFormFields();
              if(!customData){
                  return;
              }
              info.customformdata = customData
              info.customformid = that.formfields.id
          }
          //自定义表单end
                app.showLoading('提交中');
          app.post("ApiBusiness/apply", {info: info}, function (res) {
                    app.showLoading(false);
                    if(that.bset.deposit && that.bset.deposit > 0){

                    }else{
                        app.error(res.msg);
                        if(res.status == 1){
                            setTimeout(function () {
                                app.goto(app.globalData.indexurl);
                            }, 1000);
                        }
                    }

          });
        },
        isagreeChange: function (e) {
          console.log(e.detail.value);
          var val = e.detail.value;
          if (val.length > 0) {
            this.isagree = true;
          } else {
            this.isagree = false;
          }
        },
        showxieyiFun: function () {
          this.showxieyi = true;
        },
        hidexieyi: function () {
          this.showxieyi = false;
                this.isagree = true;
        },
        uploadvideo: function () {
            var that = this;
            console.log(11);
            uni.chooseVideo({
                sourceType: ['album', 'camera'],
                maxDuration: 60,
                success: function (res) {
                var tempFilePath = res.tempFilePath;
                app.showLoading('上传中');
                uni.uploadFile({
                    url: app.globalData.baseurl + 'ApiImageupload/uploadImg/aid/' + app.globalData.aid + '/platform/' + app.globalData.platform + '/session_id/' + app.globalData.session_id,
                    filePath: tempFilePath,
                    name: 'file',
                    success: function (res) {
                    app.showLoading(false);
                    var data = JSON.parse(res.data);

                    if (data.status == 1) {
                        that.video = data.url;
                    } else {
                        app.alert(data.msg);
                    }
                    },
                    fail: function (res) {
                    app.showLoading(false);
                    app.alert(res.errMsg);
                    }
                });
                },
                fail: function (res) {
                console.log(res); //alert(res.errMsg);
                }
            });
        },

        uploadimg:function(e){
            var that = this;
            var field= e.currentTarget.dataset.field
            var pics = that[field]
            if(!pics) pics = [];
            app.chooseImage(function(urls){
                for(var i=0;i<urls.length;i++){
                    pics.push(urls[i]);
                }
                if(field == 'pic') that.pic = pics;
                if(field == 'pics') that.pics = pics;
                if(field == 'zhengming') that.zhengming = pics;
            },1)
        },
        removeimg:function(e){
            var that = this;
            var index= e.currentTarget.dataset.index
            var field= e.currentTarget.dataset.field
            if(field == 'pic'){
                var pics = that.pic
                pics.splice(index,1);
                that.pic = pics;
            }else if(field == 'pics'){
                var pics = that.pics
                pics.splice(index,1);
                that.pics = pics;
            }else if(field == 'zhengming'){
                var pics = that.zhengming
                pics.splice(index,1);
                that.zhengming = pics;
            }
        },
        //自定义表单
        onchange(e) {
            const value = e.detail.value
            this.regiondata = value[0].text + ',' + value[1].text + ',' + value[2].text;
        },
        setfield:function(e){
            var field = e.currentTarget.dataset.formidx;
            var value = e.detail.value;
            this.formvaldata[field] = value;
        },
        editorBindPickerChange:function(e){
            var that = this;
            var idx = e.currentTarget.dataset.idx;
            var val = e.detail.value;
            var editorFormdata = this.editorFormdata;

            if(!editorFormdata) editorFormdata = {};
            editorFormdata[idx] = val;
            that.editorFormdata = editorFormdata
            this.test = Math.random();
            var field = e.currentTarget.dataset.formidx;
            this.formvaldata[field] = val;
        },
        checkCustomFormFields:function(e){
            var that = this;
            var subdata = this.formvaldata;
            var formcontent = that.formfields.content;
            var formid = that.formfields.id;
            var formdata = {};
            for (var i = 0; i < formcontent.length;i++){
                console.log(subdata['form' + i]);
                var value = subdata['form' + i];
                if (formcontent[i].key == 'region') {
                    if(that.regiondata){
                        value = that.regiondata;
                    }
                }
                if (formcontent[i].val3 == 1 && (subdata['form' + i] === '' || subdata['form' + i] === null || subdata['form' + i] === undefined || subdata['form' + i].length==0)){
                        app.alert(formcontent[i].val1+' 必填');return false;
                }
                if (formcontent[i].key =='switch'){
                        if (subdata['form' + i]==false){
                                value = '否'
                        }else{
                                value = '是'
                        }
                }
                if (formcontent[i].key == 'selector') {
                    if(formcontent[i].val2[subdata['form' + i]]){
                        value = formcontent[i].val2[subdata['form' + i]]
                    }

                }
                if (formcontent[i].key == 'usercard' && subdata['form' + i]!='') {
                    if(!app.isIdCard(subdata['form' + i])){
                        app.alert(formcontent[i].val1+' 格式错误');return false;
                    }
                }
                if (formcontent[i].key == 'input' && formcontent[i].val4 && subdata['form' + i]!==''){
                    if(formcontent[i].val4 == '2'){ //手机号
                        if (!app.isPhone(subdata['form' + i])) {
                            app.alert(formcontent[i].val1+' 格式错误');return false;
                        }
                    }
                    if(formcontent[i].val4 == '3'){ //身份证号
                        if (!app.isIdCard(subdata['form' + i])) {
                            app.alert(formcontent[i].val1+' 格式错误');return false;
                        }
                    }
                    if(formcontent[i].val4 == '4'){ //邮箱
                        if (!/^(.+)@(.+)$/.test(subdata['form' + i])) {
                            app.alert(formcontent[i].val1+' 格式错误');return false;
                        }
                    }
                }
                formdata['form' + i] = value;
            }
            return formdata;
        },



        uploadimg2:function(e){
			var that = this;
			var pernum = parseInt(e.currentTarget.dataset.pernum);
			if(!pernum) pernum = 1;
			var field= e.currentTarget.dataset.field
			var pics = that[field]
			if(!pics) pics = [];
			app.chooseImage(function(urls){
				for(var i=0;i<urls.length;i++){
					pics.push(urls[i]);
				}
				if(field == 'idcard') that.idcard = pics;
				if(field == 'idcard_back') that.idcard_back = pics;
			},pernum);
		},
		removeimg2:function(e){
			var that = this;
			var index= e.currentTarget.dataset.index
			var field= e.currentTarget.dataset.field
			if(field == 'idcard'){
				var idcard = that.idcard
				idcard.splice(index,1);
				that.idcard = idcard;
			}else if(field == 'idcard_back'){
				var idcard_back = that.idcard_back
				idcard_back.splice(index,1);
				that.idcard_back = idcard_back;
			}
		},
        editorChooseImage: function (e) {
            var that = this;
            var idx = e.currentTarget.dataset.idx;
            var tplindex = e.currentTarget.dataset.tplindex;
            var editorFormdata = this.editorFormdata;
            if(!editorFormdata) editorFormdata = [];
            app.chooseImage(function(data){
                editorFormdata[idx] = data[0];
                console.log(editorFormdata)
                that.editorFormdata = editorFormdata
                that.test = Math.random();

                var field = e.currentTarget.dataset.formidx;
                that.formvaldata[field] = data[0];

            })
        },
        editorChooseFile: function (e) {
            var that = this;
            var idx = e.currentTarget.dataset.idx;
            var tplindex = e.currentTarget.dataset.tplindex;
            var editorFormdata = this.editorFormdata;
            if(!editorFormdata) editorFormdata = [];
            app.chooseFile(function(data){
                editorFormdata[idx] = data;
                console.log(editorFormdata)
                that.editorFormdata = editorFormdata
                that.test = Math.random();

                var field = e.currentTarget.dataset.formidx;
                that.formvaldata[field] = data;

            })
        },
        removeimgzdy:function(e){
            var that = this;
            var idx = e.currentTarget.dataset.idx;
            var tplindex = e.currentTarget.dataset.tplindex;
            var field = e.currentTarget.dataset.formidx;
            var editorFormdata = this.editorFormdata;
            if(!editorFormdata) editorFormdata = [];
            editorFormdata[idx] = '';
            that.editorFormdata = editorFormdata
            that.test = Math.random();
            that.formvaldata[field] = '';
        },

        onStaffs(e) {
            this.staffId = e.id
        },
        searchConfirm() {},
        searchChange() {},

        // 售后弹窗
        selectSH(e) {
            const {shList} = this
            const n = shList.findIndex(n => n == e )
            if( n>=0 ) {
                this.shList.splice(n, 1);
            }else{
                this.shList.push(e)
            }
        },
        openPopu2() {
            this.popupShow2 = true
        },
        openPopu() {
            this.popupShow = true
        },
        closePopup() {
            this.popupShow = false
            this.popupShow2 = false
        },
      }
    }
</script>
<style lang="scss" scoped>
    radio{transform: scale(0.6);}
    checkbox{transform: scale(0.6);}
    .apply_box{
        padding:2rpx 24rpx 0 24rpx;
        background: #fff;
        margin: 24rpx;
        border-radius: 10rpx
    }
    .apply_title { background: #fff}
    .apply_title .qr_goback{ width:18rpx;height:32rpx; margin-left:24rpx;     margin-top: 34rpx;}
    .apply_title .qr_title{ font-size: 36rpx; color: #242424;   font-weight:bold;margin: 0 auto; line-height: 100rpx;}

    .apply_item{
        line-height: 100rpx;
        display: flex;
        border-bottom:1px solid #eee;
    }
    .apply_box .apply_item:last-child{ border:none}
    .apply_item-label{
        width: 180rpx;
    }
    .apply_item input{ width: 100%; border: none;color:#111;font-size:28rpx;}
    // text-align: right
    .apply_item input::placeholder{ color:#999999}
    .apply_item textarea{ width:100%;min-height:200rpx;padding:20rpx 0;border: none;}
    .apply_item .upload_pic{ margin:50rpx 0;background: #F3F3F3;width:90rpx;height:90rpx; text-align: center  }
    .apply_item .upload_pic image{ width: 32rpx;height: 32rpx; }
    .set-btn{width: 90%;margin:0 5%;height:96rpx;line-height:96rpx;border-radius:48rpx;color:#FFFFFF;font-weight:bold;}

    .layui-imgbox{margin-right:16rpx;margin-bottom:10rpx;font-size:24rpx;position: relative;}
    .layui-imgbox-img{display: block;width:200rpx;height:200rpx;padding:2px;border: #d3d3d3 1px solid;background-color: #f6f6f6;overflow:hidden}
    .layui-imgbox-img>image{max-width:100%;}
    .layui-imgbox-repeat{position: absolute;display: block;width:32rpx;height:32rpx;line-height:28rpx;right: 2px;bottom:2px;color:#999;font-size:30rpx;background:#fff}
    .uploadbtn{position:relative;height:200rpx;width:200rpx}
    /* 自定义字段显示 */
    /* .dp-form-item{width: 100%;display:flex;align-items: center;border-bottom:1px solid #F0F3F6;padding: 10rpx 0;} */
    /* .dp-form-item:last-child{border:0} */
    .dp-form-item{ line-height: 100rpx; display: flex;justify-content: space-between;border-bottom:1px solid #eee }
    .dp-form-item:last-child{ border:none}
    .dp-form-item input{ width: 100%; border: none;color:#111;font-size:28rpx; text-align: right}
    .dp-form-item input::placeholder{ color:#999999}
    /* .dp-form-item .label{line-height: 50rpx;width:156rpx;margin-right: 10px;flex-shrink:0;text-align: right;color: #666666;font-size: 28rpx;} */
    /* .dp-form-item .input{height: 88rpx;line-height: 88rpx;overflow: hidden;flex:1;border-radius:2px;} */
    .dp-form-item .textarea{height:180rpx;line-height:40rpx;overflow: hidden;flex:1;border:none;border-radius:2px;padding:8rpx}
    .dp-form-item .radio{height: 88rpx;line-height: 88rpx;display:flex;align-items:center}
    .dp-form-item .radio2{display:flex;align-items:center;}
    .dp-form-item .radio .myradio{margin-right:10rpx;display:inline-block;border:1px solid #aaa;background:#fff;height:32rpx;width:32rpx;border-radius:50%}
    .dp-form-item .checkbox{height: 88rpx;line-height: 88rpx;display:flex;align-items:center}
    .dp-form-item .checkbox2{display:flex;align-items:center;height: 40rpx;line-height: 40rpx;}
    .dp-form-item .checkbox .mycheckbox{margin-right:10rpx;display:inline-block;border:1px solid #aaa;background:#fff;height:32rpx;width:32rpx;border-radius:2px}
    .dp-form-item .layui-form-switch{}
    .dp-form-item .picker{height: 88rpx;line-height:88rpx;flex:1;}

    .dp-form-imgbox{margin-right:16rpx;margin-bottom:10rpx;font-size:24rpx;position: relative;}
    .dp-form-imgbox-close{position: absolute;display: block;width:32rpx;height:32rpx;right:-20rpx;top:-25rpx;color:#999;font-size:32rpx;}
    .dp-form-imgbox-close .image{width:100%;height:100%}
    .dp-form-imgbox-img{display: block;width:200rpx;height:200rpx;padding:2px; margin:2px; border: #d3d3d3 1px solid;background-color: #f6f6f6;overflow:hidden}
    .dp-form-imgbox-img>.image{max-width:100%;}
    .dp-form-imgbox-repeat{position: absolute;display: block;width:32rpx;height:32rpx;line-height:28rpx;right: 2px;bottom:2px;color:#999;font-size:30rpx;background:#fff}
    .dp-form-uploadbtn{position:relative;height:200rpx;width:200rpx}

    .popup-background {
        border-radius: 20rpx;
        padding: 0 28rpx;
        .popup {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            position: relative;
        }
        .topsearch{
            width:100%;
            padding: 14rpx 14rpx;
            background-color: white;
            margin-top: 32rpx;
            border: 1rpx solid #ddd;
        }
        .staffs{
            height: 56vh;
        }
        .staffs-item{
            padding-left: 40rpx;
            padding-right: 30rpx;
            display: flex;
            justify-content: space-between;
            height: 66rpx;
            line-height: 66rpx;

        }
        .topsearch .f1{
            height:60rpx;
            border:0;
            flex:1;
        }
        .topsearch .f1 .img{width: 32rpx;height: 32rpx;margin-left:10rpx}
        .topsearch .f1 input{height:100%;flex:1;padding:0 20rpx;font-size:30rpx;color:#333;}
        .topsearch .search-btn{
            display:flex;
            align-items:center;
            justify-content: center;
            text-align:center;
            font-size:30rpx;
            color:#fff;
            background-color:#08A346;
            width: 100rpx;
            height: 60rpx;
            line-height: 60rpx;
        }

        .search-ico-img{
            width: 42rpx;
            height: 42rpx;
        }
        .popup-title{
            position: relative;
            text-align: center;
            height: 130rpx;
            line-height: 130rpx;
        }
        .popup-title2{
            height: 68rpx;
            line-height: 68rpx;
        }
        .popup-item-line {
            border-bottom: #eee solid 1rpx;
        }
        .popup-content-item{
            min-height: 110rpx;
            border-bottom: #eee solid 1rpx;
            display: flex;
        }
        .radio-group-img{
            /* transform: translateY(10rpx); */
            margin-right: 26rpx;
            background-color: white;
        }
        .radio-group-img2{
            background-color: white;
            border: 1rpx solid #aaa;
            border-radius: 50%;
            width: 32rpx;
            height: 32rpx;
            z-index: 1;
        }
        .radio-group-img3{
            border: none;
        }
    }


    .form-item .label{color: #000;width:200rpx;}
    .form-item .input{flex:1;color: #000;}
    .set-btn{width: 90%;margin:60rpx 5%;height:96rpx;line-height:96rpx;border-radius:48rpx;color:#FFFFFF;font-weight:bold;}

    .row { background-color: #fff;padding: 30rpx;height: 300rpx;border-radius: 10rpx;margin-top: 40rpx;}
    .row-l {width: 45%;padding-top: 20rpx;}
    .row-r {width: 55%;}
    .img {width: 100%;height: 100%;}
</style>